package com.bwie.student.controller;

import com.alibaba.fastjson.JSONObject;
import com.bwie.common.domain.Student;
import com.bwie.common.domain.request.StudentRequest;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.student.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Slf4j
public class StudentController {

    @Autowired
    private StudentService studentService;

    @Autowired
    private HttpServletRequest request;


    @PostMapping("/showStudent")
    public Result<PageResult<Student>> showStudent(@RequestBody StudentRequest studentRequest){
        log.info("功能名称:列表展示,请求URI:{},请求方式:{},请求参数:{}",
                request.getRequestURI(),
                request.getMethod(),
                JSONObject.toJSONString(studentRequest));
        Result<PageResult<Student>> pageResultResult = studentService.showStudent(studentRequest);
        log.info("功能名称:列表展示,请求URI:{},请求方式:{},响应结果:{}",
                request.getRequestURI(),
                request.getMethod(),
                JSONObject.toJSONString(pageResultResult));
        return pageResultResult;
    }





}
